package com.example.jdbcsamples.program;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/**
 * 
 * @author Bora SAYINER
 * @since Feb 1, 2015 12:20:54 PM
 * @version 1.0.0
 */
public final class ConfigurationManager {

	private static final String CONF_FILE_PATH = "app.config.xml";
	private static final Properties PROPERTIES = new Properties();

	static {
		File file = new File(CONF_FILE_PATH);
		FileInputStream fileInputStream;
		try {
			fileInputStream = new FileInputStream(file);
			PROPERTIES.loadFromXML(fileInputStream);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	private ConfigurationManager() {

	}
	
	public static String getString(String key){
		return PROPERTIES.getProperty(key);
	}
	
	public static int getInt(String key){
		return Integer.valueOf(getString(key));
	}

	// private static final String DB_URL =
	// "jdbc:oracle:thin:@localhost:1521:xe";
	// private static final String DB_USER_NAME = "ex";
	// private static final String DB_PASSWORD = "ex";
	//
	// public static void main(String[] args) throws IOException {
	// Properties properties = new Properties();
	// properties.put("DB_URL", "jdbc:oracle:thin:@localhost:1521:xe");
	// properties.put("DB_USER_NAME", "ex");
	// properties.put("DB_PASSWORD", "ex");
	// File file = new File("app.config.xml");
	// FileOutputStream fileOutputStream = new FileOutputStream(file);
	// properties.storeToXML(fileOutputStream,
	// "Application configuration file.");
	// }

}
